class MinStack:
    # @param x, an integer
    
    def __init__(self):
    	self.mini = None
    	self.stk = []

    # @return an integer
    def push(self, x):
    	self.stk.append(x)
    	if self.mini is None:
    		self.mini = x
    	else:
    		if x < self.mini:
    			self.mini = x
    	return x
	'''
    def push(self, x):
    	self.stk.append(x)
    	if self.mini == None:
    		self.mini = x
    	else:
    		if x < self.mini:
    			self.mini = x
    	return x
	'''
    # @return nothing
    def pop(self):
    	top = self.stk.pop()
    	if top == self.mini:
    		if self.stk:
    			self.mini = min(self.stk)
    		else:
    			self.mini = None
    	return top

    # @return an integer
    def top(self):
    	return self.stk[-1]

    # @return an integer
    def getMin(self):
    	return self.mini

if __name__ == '__main__':
	mystk = MinStack()
	print mystk.getMin()
	mystk.push(0)
	print mystk.getMin()
	mystk.push(1)
	print mystk.getMin()
	mystk.push(2)
	print mystk.getMin()